import request from '@/utils/request'
import { CHECC_API_CMS } from '@/constants/proxy'

//获取项目管理的字典数据
const getProjectDict = () => {
  return request.post(CHECC_API_CMS + `/dictItem/codelist`, [
    'KHGL_XMZL_SOURCE', //项目来源
    'KHGL_XMZL_PROJECT_TYPE', //项目分类
    'XMZX_PATICIPATION_TYPE', //参与单位.参与类型	
    'KHGL_XMZL_IN_TYPE', //项目投入.投入类型
    'KHGL_XMZL_IN_SUBJECT', //项目投入.科目
    'KHGL_XMZL_KJ_TYPE', //工程项目类型
    'XMZX_LEVEL_TYPE', //项目级别-项目类型
    'XMZX_FUNDING_CURRENCY', //项目总费用币种
    'XMZX_PROFESSIONAL_TYPE', //专业类型
    'XMZX_ENGINEERING_FIELD', //工程领域
    'XMZX_STUDY_TYPE', //研究类别
    'XMZX_STUDY_DIRECTION', //研究方向
    'XMZX_INDUSTRY_CHAIN', //产业链
  ])
}
const getContractDict = () => {
  return request.post(CHECC_API_CMS + `/dictItem/codelist`, [
    'KHGL_HTGL_TYPE', //合同类型
    'KHGL_HTGL_NATURE', //合同性质
    'KHGL_HTGL_ENGINEERING_TYPE', //工程类型
    'KHGL_HTGL_ENGINEERING_PHASE', //工程阶段
    // 'KHGL_HTGL_FORM_TYPE', //合同表单类型
    'KHGL_HTGL_PAY_TYPE', //收支类型 
    'KHGL_HTGL_DISPUTE_METHOD', //争议解决方式
    'KHGL_HTGL_TEMPLATES_USE', //合同范本使用情况
    // 'KHGL_HTGL_OUTPUT_REPORTING_METHOD', //产值填报方式
    'XMZX_CONTRACT_STATUS', //合同状态
    'KHGL_HTGL_INCOME_TYPE', //收入类型
    // 'KHGL_HTGL_SIGN_TYPE', //合同签订方式
    'KHGL_HTGL_WAREHOUSING_METHOD', //入库方式
    // 'XMZX_BUSINESS_TYPE', //业务类型-业务类型细分
    // 'XMZX_CONTRACT_BUSINISS', //合同业务类型-业务类型细分
    'KHGL_HTGL_CHANGE_REQUEST_TYPE', //合同变更申请类型
    'KHGL_HTGL_CONTRACT_CLASSIFICATION', //合同分类
    'XMZX_HTGL_YWBK', //业务版块
  ])
}
const getUserList = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/user/getList`, params)
}
const getOrg = () => {
  return request.get(CHECC_API_CMS + `/org/tree`)
}
// 获取所在公司部门数据(权限)
export const getOrgTree = (data={}) => {
  return request({
    url: CHECC_API_CMS + '/org/tree',
    method: 'get',
    data,
  })
}
// 根据公司获取部门
export const getDeptByOrg = (id='') => {
  return request({
    url: CHECC_API_CMS + `/org/treeAll?id=${id}`,
    method: 'get'
  })
}
// 获取公司机构树(所有)
export const getAllOrgTree = () => {
  return request({
    url: CHECC_API_CMS + '/org/getSysOrgList',
    method: 'get',
  })
}
const getBusinessType = () => {
  return request.get(CHECC_API_CMS + `/businessType`)
}
const getLocation = () => {
  return request.get(CHECC_API_CMS + `/region`)
}
const getCurrencies = (params) => {
  return request.post(CHECC_API_CMS + `/common/project/getCurrencies`, params)
}
const getMainProjectList = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/common/project/getPageList`, params)
}
const getMainProjectDetail = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/common/project/detail`, params)
}
const getZhongziApi = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/common/project/apiV2`, params)
}
const getZhongziConfig = () => {
  return request.get(CHECC_API_CMS + `/common/project/getApiZzConfig`)
}
const getZhongziProject = (params) => {
  return request.post(`/three-api/api/zzlx/zzq/sendZzlxInfo`,params)
}
const getProjectFunds = (params) => {
  return request.post(`/three-api/api/zzlx/zzq/sendZzlxJfInfo`,params)
}
//获取项目下拉列表数据
const getProjectList = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/schedulePlanAdjust/getProjectName`, params)
}
//获取合同下拉列表数据
const getContractList = (id: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/schedulePlanAdjust/getContractName?projectId=${id}`)
}
//获取合同历史计划数据
const getContractHistory = (id: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/schedulePlanAdjust/getContractPlan?contractId=${id}`)
}
//流程驳回
const refuseProcess = (data: any) => {
  return request({
    url: '/process-api/act/task/over',
    method: 'post',
    data,
  })
}
// 流程--通过
const allowProcess = (data: any) => {
  return request({
    url: '/process-api/act/task/completeTaskByVo',
    method: 'post',
    data,
  })
}
//流程启动
const startProcess = (data: any) => {
  return request({
    url: '/process-api/act/run/startProcess',
    method: 'post',
    data,
  })
}
export {
  getProjectDict,
  getContractDict,
  getUserList,
  getOrg,
  getBusinessType,
  getLocation,
  getCurrencies,
  getMainProjectList,
  getMainProjectDetail,
  getZhongziApi,
  getZhongziConfig,
  getZhongziProject,
  getProjectFunds,
  getProjectList,
  getContractList,
  getContractHistory,
  refuseProcess,
  allowProcess,
  startProcess,
}
